var renderPersonalLandlordPage = {
    init: function () {
        this.bindEvent();
    },
    bindEvent: function() {
        this.getUserData( { id: getArgs().checkId } );
    },
    getUserData: function(param) {
        var _this = this;
        var methodId = "4021";
        var info = postdata(methodId,param);
        $.ajax({
            url: global.uip.url,
            type: "post",
            data: info,
            success: function (jsonData) {
                console.log( "4021",jsonData );
                if (jsonData.code == "0") {
                    var data = jsonData.res.data;
                    _this.renderPage( data );
                } else {
                    $('.all-info .weui_dialog_bd.prompt_text').html( jsonData.res.msg );
                    $('.all-info .weui_dialog_alert').show();
                }
            },
            error: function () {
                alert("接口错误");
            }
        });
    },
    renderPage: function( data ) {
        var _this = this;
        //render Page1
        $('.base-info input[name=landlordName]').val( data.landlordName );
        $('.base-info input[name=idcard-num]').val( data.idCardNo );
        $('.base-info input[name=back-name]').val( data.bankName );
        $('.base-info input[name=back-account]').val( data.bankAccount );
        $('.base-info input[name=landlord-phone]').val( data.phone );

        //render Page2
        $(".upload-idcard .id-card-01 .pic-area .fileView.preview img").attr( 'src',data.idCard );
        $(".upload-idcard .id-card-01 .pic-area").addClass('success');
        $(".upload-idcard .id-card-01 .uploadFileAddress").val( data.idCard.substring(22) );
        $('.upload-idcard input[name="landlord.positiveIdCard"]').val( data.idCard.substring(22) );

        $(".upload-idcard .id-card-02 .pic-area .fileView.preview img").attr( 'src',data.idCardBack );
        $(".upload-idcard .id-card-02 .pic-area").addClass('success');
        $(".upload-idcard .id-card-02 .uploadFileAddress").val( data.idCardBack.substring(22) );
        $('.upload-idcard input[name="landlord.backIdCard"]').val( data.idCardBack.substring(22) );

        //多张图片
        _this.renderMorePics( ".upload-idcard","personalLandlord",data.rental);
        _this.uploadIdcardNext();

        //render Page3
        if( data.clientPhone ) {
            data.clientCard = data.clientCard || '';
            $('.consignor-info input[name=consignorMobile]').val( data.clientPhone );
            $(".consignor-info .id-card-01 .pic-area .fileView.preview img").attr( 'src',data.clientCard );
            $(".consignor-info .id-card-01 .pic-area").addClass('success');
            $(".consignor-info .id-card-01 .uploadFileAddress").val( data.clientCard.substring(22) );
            $('.consignor-info input[name="consignor.positiveIdCard"]').val( data.clientCard.substring(22) );

            $(".consignor-info .id-card-02 .pic-area .fileView.preview img").attr( 'src',data.clientCardBack );
            $(".consignor-info .id-card-02 .pic-area").addClass('success');
            $(".consignor-info .id-card-02 .uploadFileAddress").val( data.clientCardBack.substring(22) );
            $('.consignor-info input[name="consignor.backIdCard"]').val( data.clientCardBack.substring(22) );
            console.log( data.entrust )
            _this.renderMorePics( ".consignor-info","consignor",data.entrust );
            _this.consignorInfoNext();
        }

        //render Page4
    },
    renderMorePics: function( selector,className,json ) {
        var _this = this;
        var outDom;
        $.each( json,function(i,val) {
            var innerDom = '<div class="upload modal1">'
                        +  '<input type="hidden" class="uploadFileAddress" value="'+ val.substring(22) +'">'
                        +  '<div class="pic-area success">'
                        +    '<div class="fileView preview">'
                        +      '<img src="'+ val +'" alt="" />'
                        +    '</div>'
                        +    '<div class="origin preview">'
                        +      '<img src="" alt="" />'
                        +    '</div>'
                        +    '<div class="tip preview">'
                        +      '<img class="jiahao" src="../../../public/img/Oval 7.png" alt="">'
                        +    '</div>'
                        +    '<input type="file" accept="image/*" name="uploadFile">'
                        +  '</div>'
                        +  '<div class="remove"></div>'
                        +'</div>';
            outDom = '<div class="'+ className +' id-card-0'+ (i+3) +'" style="background: #fff;">'+ innerDom +'</div><input type="hidden" value="'+ val.substring(22) +'" name="'+ className +'_0'+ (i+3) +'">';
            //debugger;
            $(selector+' .main .mod-upload-pic .item').append( outDom );
            _this.uploadMorePicsInit( selector,className,(i+3) );

            $(selector+" .id-card-0"+ (i+3) +" .pic-area .fileView.preview img").attr( 'src',val );
            $(selector+" .id-card-0"+ (i+3) +" .pic-area").addClass('success');
            $(selector+" .id-card-0"+ (i+3) +" .uploadFileAddress").val( val.substring(22) );
            $(selector+' input[name="'+ className +'_0'+ (i+3) +'"]').val( val.substring(22) );

        } );
    },
    uploadIdcardNext: function() {
        $('.upload-idcard .next-step').on('click',function() {
            var landlordPositiveIdCard = $('.upload-idcard input[name="landlord.positiveIdCard"]').val();
            var landlordBackIdCard = $('.upload-idcard input[name="landlord.backIdCard"]').val();
            //var landlordHouseCertificate = $('.upload-idcard input[name="certificate_03"]').val();
            console.log( $('.upload-idcard input[name="personalLandlord_03"]') );
            var personalLandlordNum = $('.personalLandlord').length;
            //console.log( certificateNum,landlordHouseCertificate );

            var personalLandlordArr = [];
            for( var i=0; i<personalLandlordNum; i++ ) {
                var index = i+3;
                var imgStr = global.uip.preAddress+$('input[name="personalLandlord_0'+ index +'"]').val();
                personalLandlordArr.push( imgStr );
            }
            //var houseImgs = imgArr.join(',');
            console.log( personalLandlordArr );


            if( !landlordPositiveIdCard ) {
                $(this).parents('.upload-idcard').find('.weui_dialog_bd.prompt_text').html('请上传身份证正面照');
                $(this).parents('.upload-idcard').find('.weui_dialog_alert').show();
                return false;
            }
            if( !landlordBackIdCard ) {
                $(this).parents('.upload-idcard').find('.weui_dialog_bd.prompt_text').html('请上传身份证反面照');
                $(this).parents('.upload-idcard').find('.weui_dialog_alert').show();
                return false;
            }
            if( !personalLandlordArr ) {
                $(this).parents('.upload-idcard').find('.weui_dialog_bd.prompt_text').html('请上传房产证复印件');
                $(this).parents('.upload-idcard').find('.weui_dialog_alert').show();
                return false;
            }

            postParams.idCard = global.uip.preAddress+landlordPositiveIdCard;
            postParams.idCardBack = global.uip.preAddress+landlordBackIdCard;
            postParams.rental = personalLandlordArr;
            console.log( postParams );
            $('.landlord.pop').show();
        });
    },
    consignorInfoNext: function() {
        $('.consignor-info .next-step').on('click',function() {
            //
            var consignorMobile = $('.consignor-info input[name=consignorMobile]').val();
            var consignorPositiveIdCard = $('.consignor-info input[name="consignor.positiveIdCard"]').val();
            var consignorBackIdCard = $('.consignor-info input[name="consignor.backIdCard"]').val();
            // var consignorHouseCertificate = $('.consignor-info input[name="consignor_03"]').val();

            var consignorNum = $('.consignor').length;
            console.log( consignorNum );

            var consignorArr = [];
            for( var i=0; i<consignorNum; i++ ) {
                var index = i+3;
                var imgStr = global.uip.preAddress+$('.consignor-info input[name="consignor_0'+ index +'"]').val();
                // var imgStr = global.uip.preAddress+$('.consignor-info id-card-0'+ index +' input.uploadFileAddress').val();
                consignorArr.push( imgStr );
            }
            //var houseImgs = imgArr.join(',');
            var myreg = /^1\d{10}$/;
            console.log( consignorArr );

            if( !consignorMobile ) {
                $(this).parents('.consignor-info').find('.weui_dialog_bd.prompt_text').html('请上传手机号');
                $(this).parents('.consignor-info').find('.weui_dialog_alert').show();
                return false;
            }
            if( !myreg.test( $('.base-info input[name=landlord-phone]').val() ) ){
            $('.weui_dialog_bd.prompt_text').html('请输入正确手机号');
            $('.weui_dialog_alert').show();
            return false;
        }
            if( !consignorPositiveIdCard ) {
                $(this).parents('.consignor-info').find('.weui_dialog_bd.prompt_text').html('请上传身份证正面照');
                $(this).parents('.consignor-info').find('.weui_dialog_alert').show();
                return false;
            }
            if( !consignorBackIdCard ) {
                $(this).parents('.consignor-info').find('.weui_dialog_bd.prompt_text').html('请上传身份证反面照');
                $(this).parents('.consignor-info').find('.weui_dialog_alert').show();
                return false;
            }
            if( !consignorArr ) {
                $(this).parents('.consignor-info').find('.weui_dialog_bd.prompt_text').html('请上传授权书');
                $(this).parents('.consignor-info').find('.weui_dialog_alert').show();
                return false;
            }

            postParams.clientPhone = consignorMobile;
            postParams.clientCard = global.uip.preAddress+consignorPositiveIdCard;
            postParams.clientCardBack = global.uip.preAddress+consignorBackIdCard;
            postParams.entrust = consignorArr;

            console.log( postParams );

             $(this).parents('.consignor-info').hide();
             $('.all-info').show();

            renderAllInfo();
        });
    },
    uploadMorePicsInit: function (selector,className,index) {
        var takeIdCard;
        $(selector+" .id-card-0"+index).uploadImage({
            url: global.uip.photoUrl,//globalUploadHost + uploadUrl,
            idCard: "8a28cd6e586797fc015867a6a2eb001d",//landlordUserInfo.id,
            defaultImage: "../../../public/img/handleCard@2x.png",
            preAddress: global.uip.preAddress,//imageAddress,
            fileImage: takeIdCard,
            onchange: function($el) {
                var list = $( selector+" .id-card-0"+ index +" .uploadFileAddress")[0], string;
                if (list) {
                    string = list.value;
                }
                $(selector+" input[name='"+ className +"_0"+ index +"']").val(string);
            }
        });
    }
};
renderPersonalLandlordPage.init();

    var postParams = {};
    postParams.landlordId = getArgs().landlordId;
    postParams.checkId  = getArgs().checkId;
    //点击弹框的 确定 按钮，弹框消失
    $('.weui_btn_dialog.primary').on('click',function() {
        $(this).parents('.weui_dialog_alert').hide();
    });

    //点击基本信息页面 下一步
    var myreg = /^1\d{10}$/;
    var reg = /(^\d{17}$)(\d|X|x)$)/; 
    $('.base-info .next-step').on('click',function() {
        if( !reg.test( $('.base-info input[name=idcard-num]').val() ) ) {
            $(this).parents('.base-info').find('.weui_dialog_bd.prompt_text').html('请输入正确身份证号');
            $(this).parents('.base-info').find('.weui_dialog_alert').show();
            return false;
        }

        if( $('.base-info input[name=landlordName]').val() == '' ) {
            $(this).parents('.base-info').find('.weui_dialog_bd.prompt_text').html('姓名必填');
            $(this).parents('.base-info').find('.weui_dialog_alert').show();
            return false;
        }
        if( $('.base-info input[name=idcard-num]').val() == '' ) {
            $(this).parents('.base-info').find('.weui_dialog_bd.prompt_text').html('身份证号必填');
            $(this).parents('.base-info').find('.weui_dialog_alert').show();
            return false;
        }
        
        if( $('.base-info input[name=back-name]').val() == '' ) {
            $(this).parents('.base-info').find('.weui_dialog_bd.prompt_text').html('收款银行必填');
            $(this).parents('.base-info').find('.weui_dialog_alert').show();
            return false;
        }
        if( $('.base-info input[name=back-account]').val() == '' ) {
            $(this).parents('.base-info').find('.weui_dialog_bd.prompt_text').html('收款银行卡号必填');
            $(this).parents('.base-info').find('.weui_dialog_alert').show();
            return false;
        }
        if( $('.base-info input[name=landlord-phone]').val() == '' ) {
            $(this).parents('.base-info').find('.weui_dialog_bd.prompt_text').html('手机号必填');
            $(this).parents('.base-info').find('.weui_dialog_alert').show();
            return false;
        }
        if( !myreg.test( $('.base-info input[name=landlord-phone]').val() ) ){
            $(this).parents('.base-info').find('.weui_dialog_bd.prompt_text').html('请输入正确手机号');
            $(this).parents('.base-info').find('.weui_dialog_alert').show();
            return false;
        }
        
        //获取用户填写的信息
        postParams.landlordName = $('.base-info input[name=landlordName]').val();
        postParams.idCardNo = $('.base-info input[name=idcard-num]').val();
        postParams.bankName = $('.base-info input[name=back-name]').val();
        postParams.bankAccount = $('.base-info input[name=back-account]').val();
        postParams.phone = $('.base-info input[name=landlord-phone]').val();

        console.log( postParams );
        $(this).parents('.base-info').hide();
        $('.upload-idcard').show();
    });

    //page2
    var positiveIdCard ;
    $(".upload-idcard .id-card-01").uploadImage({
        url: global.uip.photoUrl,// globalUploadHost + uploadUrl,
        idCard: "8a28cd6e586797fc015867a6a2eb001d",//landlordUserInfo.id,
        preAddress:global.uip.preAddress,// imageAddress,
        defaultImage: "../../../public/img/shenzhengmian@2x.png",
        fileImage: positiveIdCard,
        /*是否启动自增自减*/
        autoAppend: false,
        /*如果启动了自增减，那么这个参数必须传*/
        autoMax: 3,
        onchange: function($el) {
            var list = $(".upload-idcard .id-card-01 .uploadFileAddress")[0], string;
            if (list) {
                string = list.value;
            }
            $(".upload-idcard input[name='landlord.positiveIdCard']").val(string);
        }
    });

    var backIdCard ;
    $(".upload-idcard .id-card-02").uploadImage({
        url: global.uip.photoUrl,//globalUploadHost + uploadUrl,
        idCard: "8a28cd6e586797fc015867a6a2eb001d",//landlordUserInfo.id,

        defaultImage: "../../../public/img/shenfenzheng@2x.png",
        preAddress: global.uip.preAddress,//imageAddress,
        fileImage: backIdCard,

        onchange: function($el) {
            var list = $(".upload-idcard .id-card-02 .uploadFileAddress")[0], string;
            if (list) {
                string = list.value;
            }
            $(".upload-idcard input[name='landlord.backIdCard']").val(string);
        }
    });

    var takeIdCard;
    $(".upload-idcard .id-card-03").uploadImage({
        url: global.uip.photoUrl,//globalUploadHost + uploadUrl,
        idCard: "8a28cd6e586797fc015867a6a2eb001d",//landlordUserInfo.id,
        defaultImage: "../../../public/img/handleCard@2x.png",
        preAddress: global.uip.preAddress,//imageAddress,
        fileImage: takeIdCard,
        onchange: function($el) {
            var list = $(".upload-idcard .id-card-03 .uploadFileAddress")[0], string;
            if (list) {
                string = list.value;
            }
            $(".upload-idcard input[name='personalLandlord_03']").val(string);

            idcardAddPic();
        }
    });

    var picIndex = 3;
    function idcardAddPic() {

        picIndex++;
        var dom = '<div class="personalLandlord id-card-0'+ picIndex +'" style="background: #fff;"></div><input type="hidden" name="personalLandlord_0'+ picIndex +'">';
        $('.upload-idcard .main .mod-upload-pic .item').append( dom );

        $( ".upload-idcard .id-card-0"+picIndex ).uploadImage({
            url: global.uip.photoUrl,//globalUploadHost + uploadUrl,
            idCard: "8a28cd6e586797fc015867a6a2eb001d",//landlordUserInfo.id,
            defaultImage: "../../../public/img/handleCard@2x.png",
            preAddress: global.uip.preAddress,//imageAddress,
            fileImage: takeIdCard,
            onchange: function($el) {
                var list = $(".upload-idcard .id-card-0"+ picIndex +" .uploadFileAddress")[0], string;
                if (list) {
                    string = list.value;
                }
                $(".upload-idcard input[name='personalLandlord_0"+ picIndex +"']").val(string);
                idcardAddPic();
            }
        });
    }

    //点击上传二房东身份证页面 下一步
    // $('.upload-idcard .next-step').on('click',function() {

    //     var landlordPositiveIdCard = $('.upload-idcard input[name="landlord.positiveIdCard"]').val();
    //     var landlordBackIdCard = $('.upload-idcard input[name="landlord.backIdCard"]').val();
    //     var landlordHouseCertificate = $('.upload-idcard input[name="personal_03"]').val();

    //     var certificateNum = $('.personalLandlord').length;
    //     console.log( certificateNum );

    //     var imgArr = [];
    //     for( var i=0; i<certificateNum-1; i++ ) {
    //         var index = i+3;
    //         var imgStr = $('.upload-idcard input[name="personal_0'+ index +'"]').val();
    //         imgArr.push( imgStr );
    //     }
    //     var houseImgs = imgArr.join(',');
    //     console.log( houseImgs );


    //     if( !landlordPositiveIdCard ) {
    //         $(this).parents('.upload-idcard').find('.weui_dialog_bd.prompt_text').html('请上传身份证正面照');
    //         $(this).parents('.upload-idcard').find('.weui_dialog_alert').show();
    //         return false;
    //     }
    //     if( !landlordBackIdCard ) {
    //         $(this).parents('.upload-idcard').find('.weui_dialog_bd.prompt_text').html('请上传身份证反面照');
    //         $(this).parents('.upload-idcard').find('.weui_dialog_alert').show();
    //         return false;
    //     }
    //     if( !landlordHouseCertificate ) {
    //         $(this).parents('.upload-idcard').find('.weui_dialog_bd.prompt_text').html('请上传二房东相关收租流水');
    //         $(this).parents('.upload-idcard').find('.weui_dialog_alert').show();
    //         return false;
    //     }

    //     postParams.idCard = landlordPositiveIdCard;
    //     postParams.idCardBack = landlordBackIdCard;
    //     postParams.rental = houseImgs;
    //     console.log( postParams );
    //     $('.landlord.pop').show();
    // });

    var hasConsignor;
    $('.landlord.pop .popBottom .confirm').on('click',function() {
        hasConsignor = true;
        $('.upload-idcard').hide();
        $(this).parents('.landlord.pop').hide();
        $('.consignor-info').show();
        $('.member-info.parties-info').show();
    });

    $('.landlord.pop .popBottom .cancel').on('click',function() {
        hasConsignor = false;
        $(this).parents('.upload-idcard').hide();
        $(this).parents('.landlord.pop').hide();
        $('.all-info').show();
        renderAllInfo();
        $('.member-info.parties-info').hide();
    });

    //page3
    var positiveIdCard ;//= memObj.localData['member_memberPhotoInfo_positiveIdCard'];
    $(".consignor-info .id-card-01").uploadImage({
        url: global.uip.photoUrl,// globalUploadHost + uploadUrl,
        idCard: "8a28cd6e586797fc015867a6a2eb001d",//landlordUserInfo.id,
        preAddress:global.uip.preAddress,// imageAddress,
        defaultImage: "../../../public/img/shenzhengmian@2x.png",
        fileImage: positiveIdCard,
        /*是否启动自增自减*/
        autoAppend: false,
        /*如果启动了自增减，那么这个参数必须传*/
        autoMax: 3,
        onchange: function($el) {
            var list = $(".consignor-info .id-card-01 .uploadFileAddress")[0], string;
            if (list) {
                string = list.value;
            }
            $(".consignor-info input[name='consignor.positiveIdCard']").val(string);
        }
    });

    var backIdCard ;
    $(".consignor-info .id-card-02").uploadImage({
        url: global.uip.photoUrl,//globalUploadHost + uploadUrl,
        idCard: "8a28cd6e586797fc015867a6a2eb001d",//landlordUserInfo.id,

        defaultImage: "../../../public/img/shenfenzheng@2x.png",
        preAddress: global.uip.preAddress,//imageAddress,
        fileImage: backIdCard,
        onchange: function($el) {
            var list = $(".consignor-info .id-card-02 .uploadFileAddress")[0], string;
            if (list) {
                string = list.value;
            }
            $(".consignor-info input[name='consignor.backIdCard']").val(string);
        }
    });

    var takeIdCard;
    var picIndexConsignor = 3;
    $(".consignor-info .id-card-03").uploadImage({
        url: global.uip.photoUrl,//globalUploadHost + uploadUrl,
        idCard: "8a28cd6e5per86797fc015867a6a2eb001d",//landlordUserInfo.id,
        defaultImage: "../../../public/img/handleCard@2x.png",
        preAddress: global.uip.preAddress,//imageAddress,
        fileImage: takeIdCard,
        onchange: function($el) {
            var list = $(".consignor-info .id-card-03 .uploadFileAddress")[0], string;
            if (list) {
                string = list.value;
            }
            $(".consignor-info input[name='consignor_03']").val(string);
            consignorAddPic();
        }
    });

    function consignorAddPic() {
        picIndexConsignor++;
        var dom = '<div class="consignor id-card-0'+ picIndexConsignor +'" style="background: #fff;"></div><input type="hidden" name="consignor_0'+ picIndexConsignor +'">';
        $('.consignor-info .main .mod-upload-pic .item').append( dom );
        $( ".consignor-info .id-card-0"+picIndexConsignor ).uploadImage({
            url: global.uip.photoUrl,//globalUploadHost + uploadUrl,
            idCard: "8a28cd6e586797fc015867a6a2eb001d",//landlordUserInfo.id,
            defaultImage: "../../../public/img/handleCard@2x.png",
            preAddress: global.uip.preAddress,//imageAddress,
            fileImage: takeIdCard,
            onchange: function($el) {
                var list = $(".consignor-info .id-card-0"+ picIndexConsignor +" .uploadFileAddress")[0], string;
                if (list) {
                    string = list.value;
                }
                $(".consignor-info input[name='consignor_0"+ picIndexConsignor +"']").val(string);
                consignorAddPic();
            }
        });
    }

    //点击二房东负责人信息页面 下一步
    // $('.consignor-info .next-step').on('click',function() {
    //     //
    //     var consignorMobile = $('.consignor-info input[name=consignorMobile]').val();
    //     var consignorPositiveIdCard = $('.consignor-info input[name="consignor.positiveIdCard"]').val();
    //     var consignorBackIdCard = $('.consignor-info input[name="consignor.backIdCard"]').val();
    //     var consignorHouseCertificate = $('.consignor-info input[name="consignor_03"]').val();
    //     console.log( consignorMobile,consignorPositiveIdCard,consignorBackIdCard,consignorHouseCertificate );
    //     var consignorNum = $('.consignor').length;
    //     console.log( consignorNum );

    //     var imgArr = [];
    //     for( var i=0; i<consignorNum-1; i++ ) {
    //         var index = i+3;
    //         var imgStr = $('.consignor-info input[name="consignor_0'+ index +'"]').val();

    //         imgArr.push( imgStr );
    //     }
    //     var houseImgs = imgArr.join(',');
    //     console.log( houseImgs );

    //     if( !consignorMobile ) {
    //         $(this).parents('.consignor-info').find('.weui_dialog_bd.prompt_text').html('请上传委托人手机号');
    //         $(this).parents('.consignor-info').find('.weui_dialog_alert').show();
    //         return false;
    //     }
    //     if( !consignorPositiveIdCard ) {
    //         $(this).parents('.consignor-info').find('.weui_dialog_bd.prompt_text').html('请上传委托人身份证正面照');
    //         $(this).parents('.consignor-info').find('.weui_dialog_alert').show();
    //         return false;
    //     }
    //     if( !consignorBackIdCard ) {
    //         $(this).parents('.consignor-info').find('.weui_dialog_bd.prompt_text').html('请上传委托人身份证反面照');
    //         $(this).parents('.consignor-info').find('.weui_dialog_alert').show();
    //         return false;
    //     }
    //     if( !houseImgs ) {
    //         $(this).parents('.consignor-info').find('.weui_dialog_bd.prompt_text').html('请上传委托人授权书');
    //         $(this).parents('.consignor-info').find('.weui_dialog_alert').show();
    //         return false;
    //     }

    //     postParams.clientPhone = consignorMobile;
    //     postParams.clientCard = consignorPositiveIdCard;
    //     postParams.clientCardBack = consignorBackIdCard;
    //     postParams.entrust = houseImgs;
    //     console.log( postParams );

    //     $(this).parents('.consignor-info').hide();
    //     $('.all-info').show();

    //     renderAllInfo();
    // });

    function renderAllInfo() {
        // baseInfo
        $('.all-info span[name="landlord-name"]').html( $('.base-info input[name=landlordName]').val() );
        $('.all-info span[name="landlord-idcard"]').html( $('.base-info input[name=idcard-num]').val() );
        $('.all-info span[name="landlord-backName"]').html( $('.base-info input[name=back-name]').val() );
        $('.all-info span[name="landlord-backAccount"]').html( $('.base-info input[name=back-account]').val() );
        $('.all-info span[name="landlord-phoneNum"]').html( $('.base-info input[name=landlord-phone]').val() );
        // upload-idcard
        $('.all-info img[name="positive-idcard"]').attr( 'src',global.uip.preAddress+$(".upload-idcard input[name='landlord.positiveIdCard']").val() );
        $('.all-info img[name="back-idcard"]').attr( 'src',global.uip.preAddress+$(".upload-idcard input[name='landlord.backIdCard']").val() );

        var certificateNum = $('.personalLandlord').length;
        var dom = '';
        var index=0;
        for( var i=0; i<certificateNum; i++ ) {
            index = i+3;
            dom += '<li>'
                     +   '<img src="'+global.uip.preAddress+$('input[name="personalLandlord_0'+ index +'"]').val()+'"/>'
                     +   '<span class="hidden"><img src="'+global.uip.preAddress+$('input[name="personalLandlord_0'+ index +'"]').val()+'"/>'
                     +   '</span>'
                     + '</li>';
        }
        $('.all-info .kePublic.landlord-wrapper .msKeimgBox ul').append(dom);

        //委托人信息
        $('.all-info span[name="consignorPhone"]').html( $('.consignor-info input[name=consignorMobile]').val() );
        $('.all-info img[name="consignor-positive-card"]').attr( 'src',global.uip.preAddress+$(".consignor-info input[name='consignor.positiveIdCard']").val() );
        $('.all-info img[name="consignor-back-card"]').attr( 'src',global.uip.preAddress+$(".consignor-info input[name='consignor.backIdCard']").val() );
        var consignorNum = $('.consignor').length;
        console.log( consignorNum );
        var index2 = 0;
        var dom2 = '';
        for( var j=0; j<consignorNum; j++ ) {
            index2 = j+3;
            console.log( index2 );
            console.log( $('.consignor-info input[name="consignor_0'+ index2 +'"]') );
            dom2 += '<li>'  //$('.consignor-info id-card-0'+ index +' input.uploadFileAddress').val()
                     +   '<img src="'+global.uip.preAddress+$('.consignor-info input[name="consignor_0'+ index2 +'"]').val() +'"/>'
                     +   '<span class="hidden"><img src="'+global.uip.preAddress+$('.consignor-info input[name="consignor_0'+ index2 +'"]').val()+'"/>'
                     +   '</span>'
                     +'</li>';

        }
        $('.all-info .kePublic.consignor-wrapper .msKeimgBox ul').append(dom2);



    }
    //page4 点击汇总展示页面 下一步
    $('.all-info .next-step').on('click',function() {
        var flag = $('#aleady-read').is(':checked');
        console.log( flag );
        if( !flag == 'false' ) {
            $(this).parents('.consignor-info').find('.weui_dialog_bd.prompt_text').html('请同意房租月付条款');
            $(this).parents('.consignor-info').find('.weui_dialog_alert').show();
            return false;
        }
        postContract(postParams);
    });

    //封装ajax
    function postContract(param) {
        var methodId = "4022";
        var info = postdata(methodId,param);
        $.ajax({
                url: global.uip.url,
                type: "post",
                data: info,
                success: function (jsonData) {
                    console.log( "4022",jsonData )
                    if (jsonData.code == "0") {
                        window.location.href = 'checking.html';
                    } else {
                        $('.all-info .weui_dialog_bd.prompt_text').html( jsonData.res.msg );
                        $('.all-info .weui_dialog_alert').show();
                    }
                },
                error: function () {
                    alert("接口错误");
                }
            });
    }

    //historyBack
    $('.upload-idcard.ghy').on('click','.back-button',function(){
        $(this).parents('.upload-idcard.ghy').hide();
        $('.base-info').show();
    });
    $('.consignor-info').on('click','.back-button',function(){
        $(this).parents('.consignor-info').hide();
        $('.upload-idcard.ghy').show();
    });
    $('.all-info').on('click','.back-button',function(){
        if( hasConsignor ) {
            $(this).parents('.all-info').hide();
            $('.consignor-info').show();
        } else {
           $(this).parents('.all-info').hide();
           $('.upload-idcard.ghy').show();
        }
    });

    //点击查询授权书
    $('.check-cluase').on('click', function () {
        location.href = "contractDetail.html";
    });


